#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    string str;
    str.resize(n);
    for (int i = 0; i < n; i++) cin >> str[i];
    long long s = 0, h = 0, y = 0;
    for (int i = 0; i < n; i++)
    {
        if (str[i] == 's')   s++;
        if (str[i] == 'h')  h += s;
        if (str[i] == 'y') y += h;
    }
    cout << y;
    return 0;
}